<template>
    <div >
        <el-dialog
            :title="title"
            :close-on-click-modal="false"
            v-dialogDrag
            :visible.sync="editVisible"
            class="tableDialog"
        >
            <div class="detail">
                <p class="title">账户类型: <span>{{$dictUtils.getDictLabel("financeAccountType", editForm.companyAccountType, "")}}</span></p>
                <table class="detail-table" cellspacing="0" cellpadding="0">

<!--                    <tr class="view-container">-->
<!--                        <td class="label-container">账户类型</td>-->
<!--                        <td class="form-container">{{$dictUtils.getDictLabel("financeAccountType", editForm.companyAccountType, "")}}</td>-->
<!--                    </tr>-->
<!--                    活动账户-->
                        <tr class="view-container" v-if="editForm.companyAccountType==='1'">
                            <td class="label-container">活动账户</td>
                            <td class="form-container">{{editForm.activityAccount}}</td>
                            <td class="label-container">账户余额</td>
                            <td class="form-container">{{editForm.accountMoney}}</td>
                        </tr>
                        <tr class="view-container" v-if="editForm.companyAccountType==='1'">
                            <td class="label-container">产品单价</td>
                            <td class="form-container">{{editForm.productPrice1}}</td>
                            <td class="label-container">通知数量</td>
                            <td class="form-container">{{editForm.noticeQuantity1}}吨</td>
                        </tr>
                        <tr class="view-container" v-if="editForm.companyAccountType==='1'">
                            <td class="label-container">通知金额</td>
                            <td class="form-container">{{editForm.noticeMoney1}}</td>
                            <td class="label-container"></td>
                            <td class="form-container"></td>
                        </tr>

<!--                    业务账户-->

                    <div v-if="editForm.companyAccountType==='2'">
                        <tr class="view-container" v-if="editForm.companyAccountType==='2'">
                            <td class="label-container">业务编号</td>
                            <td class="form-container">{{editForm.codes}}</td>
                            <td class="label-container">客户名称</td>
                            <td class="form-container">{{editForm.companyName}}</td>
                        </tr>
                        <tr class="view-container" v-if="editForm.companyAccountType==='2'">
                            <td class="label-container">产品名称</td>
                            <td class="form-container">{{editForm.productName}}</td>
                            <td class="label-container">产品单价</td>
                            <td class="form-container">{{editForm.productPrice}}</td>
                        </tr>
                        <tr class="view-container" v-if="editForm.companyAccountType==='2'">
                            <td class="label-container">可用余量</td>
                            <td class="form-container">{{editForm.surpQuantity}}</td>
                            <td class="label-container">通知数量</td>
                            <td class="form-container">{{editForm.noticeQuantity}}吨</td>
                        </tr>
                        <tr class="view-container" v-if="editForm.companyAccountType==='2'">
                            <td class="label-container">通知金额</td>
                            <td class="form-container">{{editForm.noticeMoney}}</td>
                            <td class="label-container"></td>
                            <td class="form-container"></td>
                        </tr>
                    </div>
<!--                    信用账户-->

                    <tr class="view-container" v-if="editForm.companyAccountType==='3'">
                        <td class="label-container">客户名称</td>
                        <td class="form-container">{{editForm.companyName3}}</td>
                        <td class="label-container">产品名称</td>
                        <td class="form-container">{{editForm.productName3}}</td>
                    </tr>
                    <tr class="view-container" v-if="editForm.companyAccountType==='3'">
                        <td class="label-container">产品单价</td>
                        <td class="form-container">{{editForm.productPrice3}}</td>
                        <td class="label-container">可用信用量</td>
                        <td class="form-container">{{editForm.creditNumber}}</td>
                    </tr>
                    <tr class="view-container" v-if="editForm.companyAccountType==='3'">
                        <td class="label-container">通知数量</td>
                        <td class="form-container">{{editForm.noticeQuantity3}}吨</td>
                        <td class="label-container">通知金额</td>
                        <td class="form-container">{{editForm.noticeMoney3}}</td>
                    </tr>
                    <!--欠款账户-->
                    <tr class="view-container" v-if="editForm.companyAccountType==='4'">
                        <td class="label-container">客户名称</td>
                        <td class="form-container">{{editForm.companyName4}} <p class="account" v-if="editForm.debtMoney">当前欠款合计{{ editForm.debtMoney }}元</p></td>
                        <td class="label-container">产品单价</td>
                        <td class="form-container">{{editForm.productPrice4}}</td>
                    </tr>
                    <tr class="view-container" v-if="editForm.companyAccountType==='4'">
                        <td class="label-container">通知数量</td>
                        <td class="form-container">{{editForm.noticeQuantity4}}吨</td>
                        <td class="label-container">通知金额</td>
                        <td class="form-container">{{editForm.noticeMoney4}}</td>
                    </tr>
                </table>
            </div>
        </el-dialog>
    </div>
</template>

<script>
    import {selectAccount} from '@/api/business/BusinessWeight.js';
  export default {
      name: 'detail',
      data () {
          return {
              loading: false,
              method: '',
              editVisible: false,
              title: '',
              editForm: {
                  companyName1: '',
                  companyName3: '',
                  companyName4: '',
                  productName1: '',
                  productName3: '',
                  productName4: '',
                  productPrice1: '',
                  productPrice3: '',
                  productPrice4: '',
                  noticeQuantity1: '',
                  noticeQuantity3: '',
                  noticeQuantity4: '',
                  noticeMoney1: '',
                  noticeMoney3: '',
                  noticeMoney4: '',
                  debtMoney: '',
                  id: '',
                  codes: '',
                  truckTailId: '',
                  weightTime: '',
                  flowStateus: '',
                  companyAccountType: '2',
                  activityAccount: '',
                  accountMoney: '',
                  creditNumber: '',
                  businessId: '',
                  productPrice: '',
                  surpQuantity: '',
                  quantity: '',
                  money: '',
                  noticeMoney: '',
                  noticeQuantity: '',
                  nowPrice: '',
                  paymentTime: '',
                  ruleType: '',
                  paymentState: '',
                  ratio: ''
              },
              page: {
                  pageSize: 10,
                  pageNo: 1,
                  total: 0
              }
          }
      },
      methods: {
          init (method, weight, businessWeight) {
              if (method === 'info') {
                  this.businessObj = weight
                  this.businessWeightObj = businessWeight
                  this.editVisible = true
                  this.editForm.id = ''
                  this.editForm.truckTailId = ''
                  this.editForm.weightTime = ''
                  this.editForm.companyAccountType = businessWeight.companyAccountType + '';
                  console.log(businessWeight);
                  this.editForm.businessId = ''
                  this.editForm.productPrice = ''
                  this.editForm.quantity = ''
                  this.editForm.nowPrice = ''
                  this.editForm.money = ''
                  this.editForm.paymentTime = ''
                  this.editForm.ruleType = ''
                  this.editForm.paymentState = ''
                  this.editForm.ratio = ''
                  this.title = '账务通知详情'
                  this.method = method
                  this.visible = true
                  this.loading = false
                  this.selectAccount(this.editForm.companyAccountType);
              }
          },
          selectAccount (value) {
              selectAccount({
                  id: this.method === 'info' || this.method === 'edit' ? this.businessWeightObj.id : '',
                  companyAccountType: value,
                  companyId: this.businessObj.business.companyId,
                  businessId: this.businessObj.business.id,
                  dataType: this.businessObj.business.dataType,
                  payMode: this.businessObj.payMode,
                  productId: this.businessObj.product.id,
                  pageSize: this.page.pageSize,
                  pageNo: this.page.pageNo
              }).then((res) => {
                  if (res.data.code === '200') {
                      if (value === '1') {
                          this.editForm.productPrice1 = res.data.result.nowPrice;
                          this.editForm.accountMoney = res.data.result.accountMoney;
                          this.editForm.activityAccount = res.data.result.companyName + ' || ' + this.$dictUtils.getDictLabel("payMode", res.data.result.payMode, "") + ' || ' + this.$dictUtils.getDictLabel("dataType", res.data.result.dataType, "");
                          if (this.method === 'info' || this.method === 'edit') {
                              this.editForm.noticeQuantity1 = res.data.result.noticeNumber;
                              this.editForm.noticeMoney1 = res.data.result.noticeMoney;
                          }
                      } else if (value === '2') {
                          this.editForm.productPrice = res.data.result.nowPrice;
                          this.editForm.accountMoney = res.data.result.accountMoney;
                          this.editForm.codes = res.data.result.codes;
                          this.editForm.companyName = res.data.result.companyName;
                          this.editForm.productName = res.data.result.productNames;
                          this.editForm.surpQuantity = res.data.result.surpQuantity;
                          if (this.method === 'info' || this.method === 'edit') {
                              this.editForm.noticeQuantity = res.data.result.noticeNumber;
                              this.editForm.noticeMoney = res.data.result.noticeMoney;
                          }
                      } else if (value === '3') {
                          this.editForm.companyName3 = res.data.result.companyName;
                          this.editForm.productName3 = res.data.result.productNames;
                          this.editForm.productPrice3 = res.data.result.nowPrice;
                          this.editForm.creditNumber = res.data.result.creditNumber;
                          if (this.method === 'info' || this.method === 'edit') {
                              this.editForm.noticeQuantity3 = res.data.result.noticeNumber;
                              this.editForm.noticeMoney3 = res.data.result.noticeMoney;
                          }
                      } else if (value === '4') {
                          this.editForm.companyName4 = res.data.result.companyName;
                          this.editForm.productPrice4 = res.data.result.nowPrice;
                          this.editForm.debtMoney = res.data.result.debtMoney;
                          if (this.method === 'info' || this.method === 'edit') {
                              this.editForm.noticeQuantity4 = res.data.result.noticeNumber;
                              this.editForm.noticeMoney4 = res.data.result.noticeMoney;
                          }
                      }
                  }
              })
          }
      }
  }
</script>

<style lang="scss" scoped>
    .title{
        margin-bottom: 10px;
    }
    .account{
        font-size: 12px;
        color: #FF3E3E;
        line-height: 20px;
        /*position: absolute;*/
    }
</style>
